from read_list_from_file  import read_price_list_WomenJeans as read_price_list
import matplotlib.pyplot as plt; plt.rcdefaults()
import numpy as np
import matplotlib.pyplot as plt


# Example data
if __name__ == '__main__':
  
   readinfo=read_price_list.Get_Price_List()
   list=[]
   list=readinfo.get_infolist()
   times=[]
   for number in range(0,len(list))  :
        ifhas=0
        for x in range(0,len(times)):
            if(list[number]['time'].split(' ')[0]==times[x]):
                ifhas=1
                break
        if(ifhas==0):
            times.append(list[number]['time'].split(' ')[0])
   for  i in range(0,len(times)-1):
        for j in range(0,len(times)-1):
            if(times[j]>times[j+1]):
                x=times[j]
                times[j]=times[j+1]
                times[j+1]=x
   max=0
   min=list[0]['price']
   price=[]
   for number in range(0,len(list))  :
       if(list[number]['price']>max): 
           max=list[number]['price']
       if(list[number]['price']<min):
           min=list[number]['price']
   M=min
   
   while(min+10<max):
        price.append(min)
        min=min+10   
   price.append(max)
   performance=[]
   for i in range(0,len(price)):
       performance.append(0)
   print(M)
   print(max)
   print(len(price))
   print(len([performance]))
   
   
   for i in range(0,len(times)):
       for number in range(0,len(list))  :
         if(list[number]['time'].split(' ')[0]==times[i]):  
             performance[int((list[number]['price']-M)/10)]=performance[int((list[number]['price']-M)/10)]+1
   
       y_pos = np.arange(len(price))
       error = np.random.rand(len(price))

       plt.barh(y_pos, performance, xerr=error, align='center', alpha=0.4)
       plt.yticks(y_pos, price)

       plt.xlabel('Numbers')
       plt.title('Price Distribution  Of  WomenJeans_'+times[i])
       
       plt.show()